﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ServiceApplication.Service.Basic;
using CommonLibrary.DataModel.Basic;

namespace AspWebTest
{
    public partial class _Default : System.Web.UI.Page
    {
        BasicService basicService = new BasicService();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            UserEntity userEntity = basicService.QueryUserByLoginid(TextBox1.Text);

            if (userEntity == null)
            {
                MessageBox.Show(this, "不存在该用户，请确认");
                Session.Remove("loginid");
                return;
            }
            else if (userEntity.password != TextBox2.Text)
            {
                MessageBox.Show(this, "密码错误");
                Session.Remove("loginid");
                return;
            }
            else
            {
                Session["UserEntity"] = userEntity;
                Session["UserID"] = userEntity.id;
                Session["loginid"] = userEntity.loginid;
                Response.Redirect("Welcome.aspx");
            }
        }
    }
}
